import 'package:flutter/material.dart';

class HiddenWidget extends StatefulWidget {
  @override
  _HiddenWidgetState createState() => _HiddenWidgetState();
}

class _HiddenWidgetState extends State<HiddenWidget>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('隐藏控件'),
      ),
      body: Column(
        children: [
          Row(
            children: [
              Container(
                color: Colors.yellow,
                child: Column(
                  children: [
                    Visibility(
                      visible: false,
                      // maintainState: true,
                      // maintainSize: true,//报错
                      // replacement: Text('隐藏了'),
                      child: Column(
                        children: [
                          Text('Visibility'),
                          TextButton(
                              onPressed: () {
                                print('Visibility');
                              },
                              child: Text('Visibility'))
                        ],
                      ),
                    ),
                    Text('Visibility -- '),
                  ],
                ),
              ),
              Container(
                color: Colors.red,
                child: Column(
                  children: [
                    Opacity(
                      opacity: 0,
                      child: Column(
                        children: [
                          Text('Opacity'),
                          TextButton(
                              onPressed: () {
                                print('Opacity');
                              },
                              child: Text('Opacity'))
                        ],
                      ),
                    ),
                    Text('Opacity -- '),
                  ],
                ),
              ),
              Container(
                color: Colors.green,
                child: Column(
                  children: [
                    Offstage(
                      // offstage: false,
                      child: Column(
                        children: [
                          Text('Offstage'),
                          TextButton(
                              onPressed: () {
                                print('Offstage');
                              },
                              child: Text('Offstage'))
                        ],
                      ),
                    ),
                    Text('Offstage -- ')
                  ],
                ),
              ),
            ],
          ),
          Container(
            color: Colors.red,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              // spaceBetween 平分但是两端到头 spaceAround 中间平分  spaceEvenly 平分
              // mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                TextButton(
                    style: ButtonStyle(
                      textStyle:
                          MaterialStateProperty.all(TextStyle(fontSize: 14)),
                      backgroundColor: MaterialStateProperty.all(Colors.pink),
                      minimumSize: MaterialStateProperty.all(Size(100, 44)),
                    ),
                    onPressed: () {},
                    child: Column(
                      children: [
                        Image.asset(
                          'assets/images/calendar_winter.png',
                          width: 20,
                          height: 10,
                          // fit: BoxFit.fill,
                        ),
                        Text('更新年龄' * 2),
                      ],
                    )),
                TextButton(
                    style: ButtonStyle(
                      textStyle:
                          MaterialStateProperty.all(TextStyle(fontSize: 14)),
                      backgroundColor: MaterialStateProperty.all(Colors.pink),
                      minimumSize: MaterialStateProperty.all(Size(50, 44)),
                    ),
                    onPressed: () {},
                    child: Column(
                      children: [
                        Image.asset(
                          'assets/images/calendar_winter.png',
                          width: 20,
                          height: 10,
                          // fit: BoxFit.fill,
                        ),
                        Text('更新年龄'),
                      ],
                    )),
                TextButton(
                    style: ButtonStyle(
                      textStyle:
                          MaterialStateProperty.all(TextStyle(fontSize: 14)),
                      backgroundColor: MaterialStateProperty.all(Colors.pink),
                      // minimumSize: MaterialStateProperty.all(Size(300, 44)),
                    ),
                    onPressed: () {},
                    child: Column(
                      children: [
                        Image.asset(
                          'assets/images/calendar_winter.png',
                          width: 20,
                          height: 10,
                          // fit: BoxFit.fill,
                        ),
                        Text('更新年龄'),
                      ],
                    ))
              ],
            ),
          ),
        ],
      ),
    );
  }
}
